package com.chinasofti.pool;

import java.util.concurrent.*;

public class MyThreadPoolDemo03 {
    public static void main(String[] args) {
        /*
        new ThreadPoolExecutor{核心线程数量，
        最大线程数量，空闲线程最大存活时间，
         TimeUnit.SECONDS，任务队列，
         创建线程工厂，任务的拒绝策略}
         */

        ThreadPoolExecutor pool =
                new ThreadPoolExecutor(2,
                        5, 2,
                        TimeUnit.SECONDS,new ArrayBlockingQueue<>
                        (10),Executors.defaultThreadFactory(),
                        new ThreadPoolExecutor.AbortPolicy());
       pool.submit( new MyRunnable());
        pool.submit(new MyRunnable());
        pool.shutdown();
    }
}
class  MyRunnable implements  Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "在执行");
    }
}